Skip to content

Debug stream text msg improvements#10845

Open
jsarha wants to merge 2 commits into
thesofproject:mainfrom
jsarha:debug_stream_text_msg_improvements
Open

Debug stream text msg improvements#10845
jsarha wants to merge 2 commits into
thesofproject:mainfrom
jsarha:debug_stream_text_msg_improvements

Conversation

@jsarha
Copy link
Copy Markdown
Contributor

@jsarha jsarha commented Jun 4, 2026

Make ds_send_text_record() a syscall to make userspace debugging easier. And export ds_msg() to allow its usage in module code.

Copilot AI review requested due to automatic review settings June 4, 2026 22:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves debug stream text messaging for Zephyr-based SOF builds by making ds_send_text_record() callable from user space via a syscall and by exporting ds_msg() for use from module code.

Changes:

  • Register debug_stream_text_msg.h for Zephyr syscall header generation.
  • Add ds_send_text_record() API as a Zephyr syscall (when CONFIG_USERSPACE is enabled) and introduce DS_TEXT_MSG_MAX_LEN.
  • Implement syscall plumbing (z_impl_*/z_vrfy_* + marshalling include) and export ds_msg().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
zephyr/CMakeLists.txt Adds the header to Zephyr’s syscall generation inputs.
src/include/user/debug_stream_text_msg.h Introduces DS_TEXT_MSG_MAX_LEN and the ds_send_text_record() syscall/public prototype.
src/debug/debug_stream/debug_stream_text_msg.c Implements the syscall handler + verifier and exports ds_msg(); refactors text record sending path.

Comment on lines +55 to +67
void ds_vamsg(const char *format, va_list args)
{
char text[DS_TEXT_MSG_MAX_LEN];
ssize_t len;

len = vsnprintf(text, sizeof(text), format, args);

if (len < 0)
return;
len = MIN(len, sizeof(text));

ds_send_text_record(text, len);
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I'll make debug_stream_slot_send_record() a syscall instead.

Comment thread src/include/user/debug_stream_text_msg.h Outdated
void z_impl_ds_send_text_record(const char *text, size_t len)
#else
void ds_send_text_record(const char *text, size_t len)
#endif
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually we don't have to do this - we just define z_impl_...() functions and the Zephyr syscall magic calls those when userspace is disabled. Why is this needed here?

len = vsnprintf(buf.text, sizeof(buf.text), format, args);

if (len < 0)
if (!text || len == 0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a curious mix of == 0 and !x styles ;-) I won't say which one I prefer, but can we have just one of them at least within a single if? :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I drop len check. The code can cope with zero length.

Jyri Sarha added 2 commits June 5, 2026 14:51
Export ds_msg() to allow using it in loadable modules.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Make debug_stream_slot_send_record() a Zephyr syscall when
CONFIG_USERSPACE is enabled. This allows user-space threads to send
debug stream records directly.

Rename the implementation to z_impl_debug_stream_slot_send_record() and
add z_vrfy_debug_stream_slot_send_record() with K_SYSCALL_MEMORY_READ
validation of the record buffer. Register the syscall header in
CMakeLists.txt.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha jsarha force-pushed the debug_stream_text_msg_improvements branch from 776028e to d9364e5 Compare June 5, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants